from django import forms
from django.contrib.auth.models import User

from yunzhaopin import settings
class UserInfoForm(forms.Form):
    username=forms.CharField(label="用户名",min_length=3,initial="admin")
    pwd=forms.CharField(label="密码",min_length=3,
                        required=False,
                        widget=forms.PasswordInput,
                        help_text="密码至少是数字、字母组成")
    age=forms.IntegerField(label="年龄",min_value=0,max_value=150)
    sex=forms.ChoiceField(label="性别",
                          widget=forms.RadioSelect,
                          initial=1,
                          choices=((1,"男"),(2,"女")))
    city=forms.ChoiceField(label="籍贯",initial=1,choices=(("01","重庆"),("02","成都")))
    likes=forms.MultipleChoiceField(label="爱好",initial=1,
                                    widget=forms.CheckboxSelectMultiple,
                                    choices=(("01","看书"),
                                             ("02","旅游"),
                                             ("03","电影"),
                                             ("04","运动")))
    remark=forms.CharField(label="个人简介",widget=forms.Textarea)

# 登录=======================================================================
class LoginForm(forms.Form):
    username=forms.CharField(min_length=3,error_messages=
    {"required":"请输入用户名",
     "min_length":"密码必须在3位以上"})


# 注册================================================================
class RegisterForm(forms.ModelForm):
    email=forms.EmailField(label="邮箱",required=True,
                           error_messages={"required":"请输入邮箱"})
    email_code=forms.CharField(max_length=4,label="邮箱验证码",
                               error_messages={"required":"请输入邮箱验证码"})
    class Meta:
        model=User
        exclude=("last_login","date_joined")
        error_messages={
            "username":{"required":"昵称必须录入"},
            "password":{"required":"请输入密码"},
            "email":{"required":"请输入有效的邮箱"},
        }


#     modelForm
# from post.models import *
# class TopicForm(forms.ModelForm):
#     class Meta:
#         model=Topic
#         exclude=("created_time","last_modified","user")